//
//  ButtonView.m
//  EasyToTesco
//
//  Created by mc on 16/1/29.
//  Copyright © 2016年 Jack. All rights reserved.
//

#import "ButtonView.h"
#import "HeaderFileForEasyToTesco.h"

#define IMAGEWEITH 40
#define TITLELABEL 20
#define BTNMAC 10

@implementation ButtonView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat weith = self.frame.size.width;
        CGFloat heighlong = self.frame.size.height;
        CGFloat heigh = IMAGEWEITH + TITLELABEL + BTNMAC;
        self.picImage = [[UIImageView alloc] initWithFrame:CGRectMake(weith/2-IMAGEWEITH/2, heighlong/2-heigh/2, IMAGEWEITH-5, IMAGEWEITH-5)];
        [self addSubview:self.picImage];
        
        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.picImage.frame)+10, weith, TITLELABEL)];
        if (WEITH <= 320) {
            self.titleLabel.font = [UIFont systemFontOfSize:12];
        } else {
            self.titleLabel.font = [UIFont systemFontOfSize:14];
        }
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.titleLabel];
        
        self.layer.borderWidth = 0.5;
        self.layer.borderColor = [UIColor colorWithRed:217/255. green:217/255. blue:217/255. alpha:1].CGColor;
        self.backgroundColor = [UIColor whiteColor];
        
    }
    return self;
}
@end
